import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.*;

import java.util.*;

public class Student {
    private String name;
    private String studentId;
    private String examNumber;
    private String idCard;
    private int score;
    private List<VoluntaryChoice> voluntaryChoices;

    public Student(String name, String studentId, String examNumber, String idCard, int score) {
        this.name = name;
        this.studentId = studentId;
        this.examNumber = examNumber;
        this.idCard = idCard;
        this.score = score;
        this.voluntaryChoices = new ArrayList<>();
    }

    public void addVoluntaryChoice(String universityName, Major major) {
        VoluntaryChoice voluntaryChoice = new VoluntaryChoice(universityName, major);
        voluntaryChoices.add(voluntaryChoice);
    }

    public List<VoluntaryChoice> getVoluntaryChoices() {
        return voluntaryChoices;
    }

    public void printVoluntaryChoices() {
        System.out.println("\n==================== 志愿填报信息 ====================");
        System.out.printf("学生姓名: %-10s 学号: %-15s 高考成绩: %-3d\n", name, studentId, score);
        System.out.println("填报的志愿:");

        if (voluntaryChoices.isEmpty()) {
            System.out.println("没有填报任何志愿。");
        } else {
            for (int i = 0; i < voluntaryChoices.size(); i++) {
                VoluntaryChoice choice = voluntaryChoices.get(i);
                System.out.printf("%d. %-15s - %-20s\n", i + 1, choice.getUniversityName(), choice.getMajor().getName());
            }
        }
        System.out.println("====================================================");
    }

    // 搜索志愿信息
    public void searchVoluntaryChoices(String keyword) {
        System.out.println("\n==================== 搜索结果 ====================");
        boolean found = false;

        for (VoluntaryChoice choice : voluntaryChoices) {
            if (choice.getUniversityName().contains(keyword) || choice.getMajor().getName().contains(keyword)) {
                System.out.printf("学校: %-15s | 专业: %-20s\n", choice.getUniversityName(), choice.getMajor().getName());
                found = true;
            }
        }

        if (!found) {
            System.out.println("未找到符合条件的志愿信息。");
        }
        System.out.println("====================================================");
    }
}